<template>
  <el-radio-group v-model="value" :v-bind="changeValue" @change="change">
      <el-radio-button v-for="item in radioOptions" :key="item.value" :label="item.value">
        <el-badge :value="item.num" :hidden="item.num == 0">
          {{ item.label }}
        </el-badge>
      </el-radio-button>
  </el-radio-group>
</template>

<script lang="ts" setup>
  import { computed, ref } from 'vue'

  const emits = defineEmits(['change'])
  const props = defineProps<{ radioOptions: Array; changeValue: any }>()
  const value = computed({
    get: () => props.changeValue,
    set: (val) => {
      change(val)
    }
  })
  // 树节点被点击
  const change = (value) => {
    emits('change', value)
  }
</script>
<style>
  .el-badge__content.is-fixed {
    transform: translateY(-100%) translateX(130%);
  }
</style>
